/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.            */
/*                                                                 */
/*  NAME      = t_sqlserver_done_token.c                           */
/*  NOTE      =                                                    */
/*  DATE      = 2014/11/27 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <CUnit/Basic.h>

#include <frcomm.h>
#include <sqlserver/config.h>
#include <sqlserver/sqlserver_core.h>
#include <sqlserver/sqlserver_common.h>
#include <sqlserver/sqlserver_token.h>

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void __case1(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_71;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);

    bytebuff_free(&p_st_data);
    return;

}

static void __case2(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x01\x00\x00\x00\x01\x00\x00\x00\x01\x01", 10);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_YES);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_NULL);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_71R1);

    bytebuff_free(&p_st_data);
    return;

}

static void __case3(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_71;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x02\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_NO);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_71);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_74);

    bytebuff_free(&p_st_data);
    return;

}

static void __case4(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_71;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_71);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_74);

    bytebuff_free(&p_st_data);
    return;

}


static void __case5(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_73;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", 11);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);

    bytebuff_free(&p_st_data);
    return;

}

static void __case6(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_73;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", 12);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_73);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_74);

    bytebuff_free(&p_st_data);
    return;

}

static void __case7(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_71R1;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_71R1);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_71R1);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_71R1);

    bytebuff_free(&p_st_data);
    return;

}

static void __case8(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_71R1;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_NULL);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_71R1);

    bytebuff_free(&p_st_data);
    return;

}

static void __case9(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_72;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", 12);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_72);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_72);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_72);

    bytebuff_free(&p_st_data);
    return;

}


static void __case10(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_NO;
    int i_tds_ver = MSSQL_TDS_VER_71;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_TODO);

    bytebuff_free(&p_st_data);
    return;

}

static void __case11(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x01\x00\x00\x00\x01\x00\x00\x00\x01\x01", 10);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_YES);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_NULL);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_71R1);

    bytebuff_free(&p_st_data);
    return;

}

static void __case12(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_71;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x02\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_NO);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_71);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_74);

    bytebuff_free(&p_st_data);
    return;

}

static void __case13(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_71;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_71);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_74);

    bytebuff_free(&p_st_data);
    return;

}


static void __case14(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_73;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", 11);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_FAIL);

    bytebuff_free(&p_st_data);
    return;

}

static void __case15(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_73;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", 12);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_73);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_74);

    bytebuff_free(&p_st_data);
    return;

}

static void __case16(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_71R1;
    int i_max_tds_ver = MSSQL_TDS_VER_74;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_71R1);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_71R1);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_71R1);

    bytebuff_free(&p_st_data);
    return;

}

static void __case17(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_71R1;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00", 8);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_NULL);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_70);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_71R1);

    bytebuff_free(&p_st_data);
    return;

}

static void __case18(void)
{
    int i_ret = 0;
    Frbyte_Packet *p_st_data = NULL;
    int i_whole_flg = FR_YES;
    int i_tds_ver = MSSQL_TDS_VER_NULL;
    int i_min_tds_ver = MSSQL_TDS_VER_70;
    int i_max_tds_ver = MSSQL_TDS_VER_72;
    int i_try_again_flg = FR_NO;
    int i_normal_flg = 0;
    unsigned long long ull_effect_rows = 0;

    p_st_data = bytebuff_creat();
    bytebuff_add(p_st_data, (char *) "\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", 12);

    i_ret = sqlserver_done_token(p_st_data, i_whole_flg, &i_tds_ver, &i_min_tds_ver, &i_max_tds_ver, &i_try_again_flg,
                                 &i_normal_flg, &ull_effect_rows);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_EQUAL(i_normal_flg, FR_YES);
    CU_ASSERT_EQUAL(ull_effect_rows, 1);
    CU_ASSERT_EQUAL(i_try_again_flg, FR_NO);
    CU_ASSERT_EQUAL(i_tds_ver, MSSQL_TDS_VER_72);
    CU_ASSERT_EQUAL(i_min_tds_ver, MSSQL_TDS_VER_72);
    CU_ASSERT_EQUAL(i_max_tds_ver, MSSQL_TDS_VER_72);

    bytebuff_free(&p_st_data);
    return;
}

int add_suite_sqlserver_done_token(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" sqlserver_done_token()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    //增加测试用例
    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL ||
        CU_add_test(pSuite, "case3", __case3) == NULL ||
        CU_add_test(pSuite, "case4", __case4) == NULL ||
        CU_add_test(pSuite, "case5", __case5) == NULL ||
        CU_add_test(pSuite, "case6", __case6) == NULL ||
        CU_add_test(pSuite, "case7", __case7) == NULL ||
        CU_add_test(pSuite, "case8", __case8) == NULL ||
        CU_add_test(pSuite, "case9", __case9) == NULL ||
        CU_add_test(pSuite, "case10", __case10) == NULL ||
        CU_add_test(pSuite, "case11", __case11) == NULL ||
        CU_add_test(pSuite, "case12", __case12) == NULL ||
        CU_add_test(pSuite, "case13", __case13) == NULL ||
        CU_add_test(pSuite, "case14", __case14) == NULL ||
        CU_add_test(pSuite, "case15", __case15) == NULL ||
        CU_add_test(pSuite, "case16", __case16) == NULL ||
        CU_add_test(pSuite, "case17", __case17) == NULL ||
        CU_add_test(pSuite, "case18", __case18) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
